package com.changcheng.explorer.dialog;

import com.changcheng.explorer.R;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

/**
 * 文件重命名对话框
 * @author Administrator
 *
 */
public class FSRenameDialog extends Dialog {
	
	// 新名称
	private String newName;

	public String getNewName() {
		return newName;
	}

	public void setNewName(String newName) {
		this.newName = newName;
	}

	public FSRenameDialog(Context context, String title) {
		super(context);
		// 自定义视图
		this.setContentView(R.layout.file_rename_dialog);
		this.setCancelable(true);
		this.setTitle(title);

		// 为取消按钮添加事件
		Button cancel = (Button) this
				.findViewById(R.id.file_bt_rename_cancel);
		cancel.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				FSRenameDialog.this.cancel();
			}
		});

		// 为确定按钮添加事件
		Button ok = (Button) this.findViewById(R.id.file_bt_rename_ok);
		ok.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				EditText editText = (EditText) FSRenameDialog.this.findViewById(R.id.file_et_rename_name);
				FSRenameDialog.this.newName = editText.getText().toString();
				FSRenameDialog.this.dismiss();
			}
		});
	}
}
